package com.wetool.wechat.service;

import com.wetool.wechat.feign.WechatOfficialFeignClient;
import com.wetool.wechat.model.official.menu.ButtonType;
import com.wetool.wechat.model.official.menu.MenuButton;
import com.wetool.wechat.model.official.menu.MenuGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 微信自定义菜单服务
 */
@Service
public class WechatMenuService {
    @Autowired
    private WechatOfficialFeignClient wechatOfficialFeignClient;

    @Autowired
    private WechatOfficialService wechatOfficialService;

    /**
     * 创建菜单
     */
    public void createMenu() {

        MenuGroup menuGroup = new MenuGroup();

        MenuButton menuButton = new MenuButton(ButtonType.CLICK, "test");
        menuGroup.addButton(menuButton);

        String accessToken = this.wechatOfficialService.getAccessToken();

        this.wechatOfficialFeignClient.createMenu(accessToken, menuGroup);

    }
}
